#!/usr/bin/python

# Get references

from pyodm.document import Document
from pyodm.fields import *
from pyodm.criteria import Criteria

class ReferreeDocument(Document):
    field = StringField()

class ReferrerDocument(Document):
    field1 = StringField()
    field2 = IntegerField()
    ref = ReferenceField(ReferreeDocument)


crit = Criteria("field1", "=", "test1")
obj = ReferrerDocument.get([crit])[0]

refs = obj.ref.get()
for ref in refs:
    print "Key: %s\nfield: %s\n=================\n" % (ref.getKey(), ref.field)
